assemblyx86fasmas86

Convert an as86 to fasm


I'm trying to convert this bit of assembly for as86 to fasm. I have 3 questions:

1) Why seg es given an error: illegal instruction. this is not valid in 16-bit?

2) Is mov byte [0],0x41(FASM syntax) exactly equivalent to mov [0],#0x41(as86 syntax)? if isn't,can you show me the equivalent to?

3) Why entry start give an error in FASM?

Here's the assemblies codes:

as86

entry start
start:
       mov ax,#0xb800
       mov es,ax
       seg es
       mov [0],#0x41
       seg es
       mov [1],#0x1f
 loop1: jmp loop1

and the fasm version that I wrote:

FASM

use16
format binary

start:
    mov ax,0xb800
    mov es,ax
    seg es
    mov byte [0],0x41
    seg es
    mov byte [1],0x1f
loop1:  jmp loop1

Solution

  • Correct syntax is:

    mov byte [es:0],0x41    ;I'm not sure if this instruction is supported under 16 bit CPU
    

    or

    push bx 
    mov  bx,0   ;you can use also: xor  bx, bx
    mov  byte [es:bx],0x41
    pop  bx